<?php
/* This file is part of Mirasol CMS
   (C) 2009, 2011 by Alban Technologies. Written by Chris Alban Hansen.
   Released under the terms of the GNU General Public License.
   See COPYING in the top level directory of the Mirasol CMS installation. */

include "{$_SERVER['DOCUMENT_ROOT']}/includes/readconf.php";

if (!defined ("_DB_PHP_"))
{
  define ("_DB_PHP_", "1");

  function db_close ($connection)
  {
    /* Close connection to database */
    mysql_close ($connection);
  }

  function db_maketablename ($defname)
  {
    $conf_db = readsiteconf ("database");
    return $conf_db['dbprefix']."_".$defname;
  }

  function db_open ()
  {
    /* Read settings for the database connection... */
    $conf_db = readsiteconf ("database");
    
    /* ...and connect to the database */
    $connection = mysql_connect ($conf_db['server'], $conf_db['user'], $conf_db['password']);
    if (!$connection)
      die ("Could not connect: ".mysql_error ());
    mysql_select_db ($conf_db['dbname'], $connection);
    
    return $connection;
  }
}
?>
